﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using HtmlMultiFileEditor.Model;

namespace HtmlMultiFileEditor.Controller
{
    public class MessageHandlerController
    {
        #region "Singleton"

        private static MessageHandlerController messageHandlerController = new MessageHandlerController();

        private MessageHandlerController() { }

        public static MessageHandlerController Instance
        {
            get
            {
                return messageHandlerController;

            }
        }

        #endregion

        #region "Events"

        public delegate void MessageChangedHandler(object sender, string eMessage);

        public event MessageChangedHandler MessageChanged;

        #endregion

        #region "Public"

        public void UpdateMessage(string message)
        {

            Manager.Instance.Message = message;
            if (MessageChanged != null)
            {

                MessageChanged(this, message);
            }
        }

        public void FilesLoadedMessage()
        {
            int fileNumber = FileHandler.Instance.FileList.Length;
            string message = String.Empty;
            if (fileNumber == 1)
            {
                message = fileNumber + " file loaded";
                UpdateMessage(message);
            }
            else
            {
                message = fileNumber + " files loaded";

            }
        }

        public void FilesSelectedMessage()
        {
            int fileNumber = FileHandler.Instance.FileListSelected.Length;
            string message = String.Empty;
            if (fileNumber == 1)
            {
                message = fileNumber + " file selected";
                UpdateMessage(message);
            }
            else
            {
                message = fileNumber + " files selected";

            }

        }

        public void FileModifiedMessage(string file)
        {

            string message = Path.GetFileName(file) + " file Modified.";
            UpdateMessage(message);
        }

        public void CurrentFileNameMessage(string file)
        {
            UpdateMessage(Path.GetFileName(file) + " is selected");

        }

        #endregion
    }
}
